< previous page page_101 next page >

Page 101
In this code, youll notice a couple of new items. First, youre using an ampersand (&) character to concatenate a literal string with the value thats returned from the List() property of the list box. Theres also an underscore at the end of the MsgBox line. This is the line continuation character, which can be used to continue a line of code on a new line.
The ListIndex property is used as an index into the List() property array. Whenever the user clicks an item in the list box, the ListIndex property is set to the number of the item selected. The List() property is an array of the items in the list box. Therefore, you need an index into that array. The ListIndex property can be used for this. Figure 5.3 shows you the relationship between the List() property and the ListIndex property.
8160-0101a.gif
Figure 5.3
List() and ListIndex
properties described.
The ListBox_ItemCheck Event
The ItemCheck() event is fired whenever the list box Style property is set to 1-Check Box and the user clicks the check box of an item. This is different from the Click() event, which Click() occurs whenever an item is highlighted. The ItemCheck() event occurs only when the user clicks the check box area of an item in a list box. Heres an example:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub lstHealth_ItemCheck(Item As Integer)
   MsgBox "The Item Selected Is " & _
         lstHealth.List(Item)
End Sub
The ItemCheck() method is passed the item number checked. You can use the Item parameter as an index into the List() array.

 
< previous page page_101 next page >

If you like this book, buy it!